package longrise.phone.com.itssnew.activity;

import android.content.ContentValues;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import com.longrise.LEAP.Base.Objects.EntityBean;
import com.longrise.LEAP.Base.Objects.EntityBeanSet;
import com.longrise.android.util.StringUtils;

import org.litepal.crud.DataSupport;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import butterknife.Bind;
import butterknife.OnClick;
import longrise.phone.com.itssnew.R;
import longrise.phone.com.itssnew.bean.CompanyBean;
import longrise.phone.com.itssnew.bean.Constant;
import longrise.phone.com.itssnew.bean.JZSQGloble;
import longrise.phone.com.itssnew.utils.CommonUtil;
import longrise.phone.com.itssnew.utils.SPUtil;
import longrise.phone.com.itssnew.widget.LoadDialog;


public class ScoreOperationsActivity extends BaseActivity {
    @Bind(R.id.top_title)
    TextView topTitle;
    @Bind(R.id.score_button)
    Button scoreButton;
    @Bind(R.id.onePoOnePoOne_operations)
    EditText onePoOnePoOneOperations;
    @Bind(R.id.onePoTwoPoOne_operations)
    EditText onePoTwoPoOneOperations;
    @Bind(R.id.twoPoOnePoOne_operations)
    EditText twoPoOnePoOneOperations;
    @Bind(R.id.twoPoTwoPoOne_operations)
    EditText twoPoTwoPoOneOperations;
    @Bind(R.id.twoPoThreePoOne_operations)
    EditText twoPoThreePoOneOperations;
    @Bind(R.id.twoPoFourPoOne_operations)
    EditText twoPoFourPoOneOperations;
    @Bind(R.id.twoPoFourPoTwo_operations)
    EditText twoPoFourPoTwoOperations;
    @Bind(R.id.twoPoFourPoThree_operations)
    EditText twoPoFourPoThreeOperations;
    @Bind(R.id.threePoOnePoOne_operations)
    EditText threePoOnePoOneOperations;
    @Bind(R.id.threePoOnePoTwo_operations)
    EditText threePoOnePoTwoOperations;
    @Bind(R.id.threePoOnePoThree_operations)
    EditText threePoOnePoThreeOperations;
    @Bind(R.id.threePoOnePoFour_operations)
    EditText threePoOnePoFourOperations;
    @Bind(R.id.threePoOnePoFive_operations)
    EditText threePoOnePoFiveOperations;
    @Bind(R.id.threePoOnePoSix_operations)
    EditText threePoOnePoSixOperations;
    @Bind(R.id.threePoOnePoSeven_operations)
    EditText threePoOnePoSevenOperations;
    @Bind(R.id.threePoOnePoEight_operations)
    EditText threePoOnePoEightOperations;
    @Bind(R.id.threePoTwoPoOne_operations)
    EditText threePoTwoPoOneOperations;
    @Bind(R.id.threePoTwoPoTwo_operations)
    EditText threePoTwoPoTwoOperations;
    @Bind(R.id.threePoTwoPoThree_operations)
    EditText threePoTwoPoThreeOperations;
    @Bind(R.id.threePoThreePoOne_operations)
    EditText threePoThreePoOneOperations;
    @Bind(R.id.threePoThreePoTwo_operations)
    EditText threePoThreePoTwoOperations;
    @Bind(R.id.threePoThreePoThree_operations)
    EditText threePoThreePoThreeOperations;
    @Bind(R.id.threePoThreePoFour_operations)
    EditText threePoThreePoFourOperations;
    @Bind(R.id.threePoFourPoOne_operations)
    EditText threePoFourPoOneOperations;
    @Bind(R.id.threePoFourPoTwo_operations)
    EditText threePoFourPoTwoOperations;
    @Bind(R.id.threePoFourPoThree_operations)
    EditText threePoFourPoThreeOperations;
    @Bind(R.id.threePoFivePoOne_operations)
    EditText threePoFivePoOneOperations;
    @Bind(R.id.threePoFivePoTwo_operations)
    EditText threePoFivePoTwoOperations;
    @Bind(R.id.fourPoOne_operations)
    EditText fourPoOneOperations;
    @Bind(R.id.fourPoTwo_operations)
    EditText fourPoTwoOperations;
    @Bind(R.id.fourPoThree_operations)
    EditText fourPoThreeOperations;
    @Bind(R.id.expert_operations)
    EditText expertOperations;

    private String mId;
    private String mCode;
    private int mType;
    private LoadDialog mLoadDialog;
    private List<EditText> mEditTextArray;
    private List<String> mScoreTextArray;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        initView();
    }

    @Override
    public int bindLayoutId() {
        return R.layout.activity_score_operations;
    }

    private void initView() {
        mId = getIntent().getStringExtra("id");
        mCode = getIntent().getStringExtra("code");
        topTitle.setText("(" + mCode + ")评分列表");
        mType = SPUtil.getSharedIntData(this, Constant.SPOPERATIONSORDESIGN);
        setEditTextList();
        setScoreTextList();
        setButtonAndEditTextVisible();
        getAllScoreEntityBean();
    }

    private void setButtonAndEditTextVisible(){
        boolean isSubmit = getIntent().getBooleanExtra("isSubmit", false);
        if(isSubmit){
            scoreButton.setVisibility(View.GONE);
            for (EditText mEditText:mEditTextArray) {
                mEditText.setEnabled(false);
                mEditText.setClickable(false);
            }
        }else {
            scoreButton.setVisibility(View.VISIBLE);
            for (EditText mEditText:mEditTextArray) {
                mEditText.setEnabled(true);
                mEditText.setClickable(true);
            }
        }

    }

    private void setEditTextList() {
        mLoadDialog = new LoadDialog(this);
        mLoadDialog.show();
        mEditTextArray = new ArrayList<>();
        mEditTextArray.add(onePoOnePoOneOperations);
        mEditTextArray.add(onePoTwoPoOneOperations);
        mEditTextArray.add(twoPoOnePoOneOperations);
        mEditTextArray.add(twoPoTwoPoOneOperations);
        mEditTextArray.add(twoPoThreePoOneOperations);
        mEditTextArray.add(twoPoFourPoOneOperations);
        mEditTextArray.add(twoPoFourPoTwoOperations);
        mEditTextArray.add(twoPoFourPoThreeOperations);
        mEditTextArray.add(threePoOnePoOneOperations);
        mEditTextArray.add(threePoOnePoTwoOperations);
        mEditTextArray.add(threePoOnePoThreeOperations);
        mEditTextArray.add(threePoOnePoFourOperations);
        mEditTextArray.add(threePoOnePoFiveOperations);
        mEditTextArray.add(threePoOnePoSixOperations);
        mEditTextArray.add(threePoOnePoSevenOperations);
        mEditTextArray.add(threePoOnePoEightOperations);
        mEditTextArray.add(threePoTwoPoOneOperations);
        mEditTextArray.add(threePoTwoPoTwoOperations);
        mEditTextArray.add(threePoTwoPoThreeOperations);
        mEditTextArray.add(threePoThreePoOneOperations);
        mEditTextArray.add(threePoThreePoTwoOperations);
        mEditTextArray.add(threePoThreePoThreeOperations);
        mEditTextArray.add(threePoThreePoFourOperations);
        mEditTextArray.add(threePoFourPoOneOperations);
        mEditTextArray.add(threePoFourPoTwoOperations);
        mEditTextArray.add(threePoFourPoThreeOperations);
        mEditTextArray.add(threePoFivePoOneOperations);
        mEditTextArray.add(threePoFivePoTwoOperations);
        mEditTextArray.add(fourPoOneOperations);
        mEditTextArray.add(fourPoTwoOperations);
        mEditTextArray.add(fourPoThreeOperations);
        mEditTextArray.add(expertOperations);
        Log.d("lyitss",mEditTextArray.size()+"");
    }

    private void setScoreTextList() {
        mScoreTextArray = new ArrayList<>();
        mScoreTextArray.add("1.1.1");
        mScoreTextArray.add("1.2.1");
        mScoreTextArray.add("2.1.1");
        mScoreTextArray.add("2.2.1");
        mScoreTextArray.add("2.3.1");
        mScoreTextArray.add("2.4.1");
        mScoreTextArray.add("2.4.2");
        mScoreTextArray.add("2.4.3");
        mScoreTextArray.add("3.1.1");
        mScoreTextArray.add("3.1.2");
        mScoreTextArray.add("3.1.3");
        mScoreTextArray.add("3.1.4");
        mScoreTextArray.add("3.1.5");
        mScoreTextArray.add("3.1.6");
        mScoreTextArray.add("3.1.7");
        mScoreTextArray.add("3.1.8");
        mScoreTextArray.add("3.2.1");
        mScoreTextArray.add("3.2.2");
        mScoreTextArray.add("3.2.3");
        mScoreTextArray.add("3.3.1");
        mScoreTextArray.add("3.3.2");
        mScoreTextArray.add("3.3.3");
        mScoreTextArray.add("3.3.4");
        mScoreTextArray.add("3.4.1");
        mScoreTextArray.add("3.4.2");
        mScoreTextArray.add("3.4.3");
        mScoreTextArray.add("3.5.1");
        mScoreTextArray.add("3.5.2");
        mScoreTextArray.add("4.1.1");
        mScoreTextArray.add("4.2.1");
        mScoreTextArray.add("4.3.1");
        mScoreTextArray.add("意见");
    }

    @OnClick({R.id.top_left, R.id.score_button})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.top_left:
                showScoreNotSaveDialog(ScoreOperationsActivity.this);
                break;
            case R.id.score_button:
                submitScore();
                break;
        }
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if(keyCode == KeyEvent.KEYCODE_BACK){
            showScoreNotSaveDialog(ScoreOperationsActivity.this);
        }
        return false;
    }

    /**
     * 查询打分数据,先从数据库获取，再从网络获取
     */
    private void getAllScoreEntityBean() {
        setEditTextWatcher();
        List<CompanyBean> newsList = DataSupport.where("companyId = ?", mId).find(CompanyBean.class);
        if (newsList != null && newsList.size() > 0) {
            setEditTextOnDb(newsList.get(0));
            mLoadDialog.dismiss();
            return;
        }
        if(loginInvalid(this)) return;
        JZSQGloble.getInstance(this).call("getAllRateOfcompany", EntityBeanSet.class, new JZSQGloble.OnCallFinishListener() {
            @Override
            public void onCallFinish(Object bean) {
                mLoadDialog.dismiss();
                if (bean == null || ScoreOperationsActivity.this.isFinishing()) return;
                newSoreDb();
                EntityBeanSet mEntityBeans = (EntityBeanSet) bean;
                setEditTextOnInternet(mEntityBeans);
            }
        }, mId);
    }

    /**
     * 新建数据库
     */
    private void newSoreDb(){
        CompanyBean companyBean = new CompanyBean();
        companyBean.setId(mId);
        companyBean.save();
    }

    /**
     * 观察打分范围
     */
    private void setEditTextWatcher() {
        for (int i = 0; i < mEditTextArray.size(); i++) {
            final EditText editText = mEditTextArray.get(i);
            final String scoreText = mScoreTextArray.get(i);
            editText.addTextChangedListener(new TextWatcher() {
                @Override
                public void beforeTextChanged(CharSequence s, int start, int count, int after) {
                }

                @Override
                public void onTextChanged(CharSequence s, int start, int before, int count) {
                }

                @Override
                public void afterTextChanged(Editable s) {
                    String changeString = s.toString().trim();
                    if(scoreText.equals("意见")){
                        updateScoreToDb(null,changeString);
                        return;
                    }
                    ifNotCrossingTheLine(scoreText,changeString,editText);
                }
            });
        }
    }

    /**
     * 判断打分是否超过范围 ,保存到数据库
     * @param scoreText 标题1.1.1
     * @param str 分数
     * @param editText 所在edittext
     * @return
     */
    private void ifNotCrossingTheLine(String scoreText,String str, EditText editText) {
        if(StringUtils.isEmpty(str)){
            updateScoreToDb(scoreText,"");
        }else {
            boolean botCrossingTheLine = false;
            Double value = Double.parseDouble(str);
            if (editText == mEditTextArray.get(0)) {
                botCrossingTheLine = value >= 0.00 && value <= 20.00;
            } else if (editText == mEditTextArray.get(1)) {
                botCrossingTheLine = value >= 0.00 && value <= 10.00;
            }else if (editText == mEditTextArray.get(2)) {
                botCrossingTheLine = value >= 0.00 && value <= 10.00;
            }else if (editText == mEditTextArray.get(3)) {
                botCrossingTheLine = value >= 0.00 && value <= 10.00;
            }else if (editText == mEditTextArray.get(4)) {
                botCrossingTheLine = value >= 0.00 && value <= 5.00;
            }else if (editText == mEditTextArray.get(5)) {
                botCrossingTheLine = value >= 0.00 && value <= 5.00;
            }else if (editText == mEditTextArray.get(6)) {
                botCrossingTheLine = value >= 0.00 && value <= 5.00;
            }else if (editText == mEditTextArray.get(7)) {
                botCrossingTheLine = value >= 0.00 && value <= 5.00;
            }else if (editText == mEditTextArray.get(8)) {
                botCrossingTheLine = value >= 0.00 && value <= 20.00;
            }else if (editText == mEditTextArray.get(9)) {
                botCrossingTheLine = value >= 0.00 && value <= 20.00;
            }else if (editText == mEditTextArray.get(10)) {
                botCrossingTheLine = value >= 0.00 && value <= 20.00;
            }else if (editText == mEditTextArray.get(11)) {
                botCrossingTheLine = value >= 0.00 && value <= 20.00;
            }else if (editText == mEditTextArray.get(12)) {
                botCrossingTheLine = value >= 0.00 && value <= 20.00;
            }else if (editText == mEditTextArray.get(13)) {
                botCrossingTheLine = value >= 0.00 && value <= 20.00;
            }else if (editText == mEditTextArray.get(14)) {
                botCrossingTheLine = value >= 0.00 && value <= 20.00;
            }else if (editText == mEditTextArray.get(15)) {
                botCrossingTheLine = value >= 0.00 && value <= 20.00;
            }else if (editText == mEditTextArray.get(16)) {
                botCrossingTheLine = value >= 0.00 && value <= 15.00;
            }else if (editText == mEditTextArray.get(17)) {
                botCrossingTheLine = value >= 0.00 && value <= 20.00;
            }else if (editText == mEditTextArray.get(18)) {
                botCrossingTheLine = value >= 0.00 && value <= 15.00;
            }else if (editText == mEditTextArray.get(19)) {
                botCrossingTheLine = value >= 0.00 && value <= 30.00;
            }else if (editText == mEditTextArray.get(20)) {
                botCrossingTheLine = value >= 0.00 && value <= 20.00;
            }else if (editText == mEditTextArray.get(21)) {
                botCrossingTheLine = value >= 0.00 && value <= 20.00;
            }else if (editText == mEditTextArray.get(22)) {
                botCrossingTheLine = value >= 0.00 && value <= 10.00;
            }else if (editText == mEditTextArray.get(23)) {
                botCrossingTheLine = value >= 0.00 && value <= 15.00;
            }else if (editText == mEditTextArray.get(24)) {
                botCrossingTheLine = value >= 0.00 && value <= 20.00;
            }else if (editText == mEditTextArray.get(25)) {
                botCrossingTheLine = value >= 0.00 && value <= 15.00;
            }else if (editText == mEditTextArray.get(26)) {
                botCrossingTheLine = value >= 0.00 && value <= 15.00;
            }else if (editText == mEditTextArray.get(27)) {
                botCrossingTheLine = value >= 0.00 && value <= 15.00;
            }else if (editText == mEditTextArray.get(28)) {
                botCrossingTheLine = value >= 0.00 && value <= 20.00;
            }else if (editText == mEditTextArray.get(29)) {
                botCrossingTheLine = value >= 0.00 && value <= 15.00;
            }else if (editText == mEditTextArray.get(30)) {
                botCrossingTheLine = value >= 0.00 && value <= 25.00;
            }
            if(botCrossingTheLine)updateScoreToDb(scoreText,str);
            else {
                CommonUtil.showToast(ScoreOperationsActivity.this, "请在打分范围内打分并且只能输入整数");
                editText.setText("");
            }
        }
    }

    /**
     * 提交数据，保存到后台
     */
    private void submitScore() {
        if (editTextHaveEmpty()) return;
        if(StringUtils.isEmpty(expertOperations.getText().toString().trim())) {
            CommonUtil.showToast(this, "意见不能为空");
            return;
        }
        if(loginInvalid(this)) return;
        mLoadDialog = new LoadDialog(this);
        mLoadDialog.show();
        Map<String, Double> stringDoubleMap = setNetWorkHashMap();
        EntityBean bean = new EntityBean();
        bean.put("Opinion", expertOperations.getText().toString().trim());
        bean.put("standardtype", mType);
        JZSQGloble.getInstance(this).call("saveRateScore", Boolean.class, new JZSQGloble.OnCallFinishListener() {
            @Override
            public void onCallFinish(Object bean) {
                mLoadDialog.dismiss();
                if(null == bean)return;
                boolean mEntityBeans = (Boolean) bean;
                if (mEntityBeans) {
                    CommonUtil.showToast(ScoreOperationsActivity.this, "保存成功");
                    DataSupport.deleteAll(CompanyBean.class, "companyId = ?", mId);
                    rxManager.post("refresh", "");
                    finish();
                } else CommonUtil.showToast(ScoreOperationsActivity.this, "网络保存失败");
            }
        }, mId, stringDoubleMap, bean);
    }

    /**
     * 设置edittext 的map，保存的参数之一
     *
     * @return
     */
    private Map<String, Double> setNetWorkHashMap() {
        Map<String, Double> mSumMap = new HashMap<String, Double>();
        for (int i = 0; i < mEditTextArray.size()-1; i++) {
            EditText editText = mEditTextArray.get(i);
            Double editTextSubmit = Double.parseDouble(editText.getText().toString().trim());
            mSumMap.put(mScoreTextArray.get(i), editTextSubmit);
        }
        return mSumMap;
    }


    /**
     * 有项目未打分
     *
     * @return
     */
    private boolean editTextHaveEmpty() {
        Boolean editTextHaveEmpty=false;
        for(int i = 0; i< mEditTextArray.size();i++){
            String mEditTextArrayPositionString = mEditTextArray.get(i).getText().toString().trim();
            if (StringUtils.isEmpty(mEditTextArrayPositionString)){
                CommonUtil.showToast(this, mScoreTextArray.get(i) + "项未填写，请检查");
                editTextHaveEmpty = true;
                break;
            }editTextHaveEmpty=false;
        }
        return editTextHaveEmpty;
    }

    /**
     * 从数据库数据初始化EditText的打分值
     */
    private void setEditTextOnDb(CompanyBean mCompanyBean) {
        mEditTextArray.get(0).setText(CommonUtil.nullToString(mCompanyBean.getOneOne()));
        mEditTextArray.get(1).setText(CommonUtil.nullToString(mCompanyBean.getOneTwo()));
        mEditTextArray.get(2).setText(CommonUtil.nullToString(mCompanyBean.getTwoOne()));
        mEditTextArray.get(3).setText(CommonUtil.nullToString(mCompanyBean.getTwoTwo()));
        mEditTextArray.get(4).setText(CommonUtil.nullToString(mCompanyBean.getTwoThree()));
        mEditTextArray.get(5).setText(CommonUtil.nullToString(mCompanyBean.getTwoFourOne()));
        mEditTextArray.get(6).setText(CommonUtil.nullToString(mCompanyBean.getTwoFourTwo()));
        mEditTextArray.get(7).setText(CommonUtil.nullToString(mCompanyBean.getTwoFourThree()));
        mEditTextArray.get(8).setText(CommonUtil.nullToString(mCompanyBean.getThreeOneOne()));
        mEditTextArray.get(9).setText(CommonUtil.nullToString(mCompanyBean.getThreeOneTwo()));
        mEditTextArray.get(10).setText(CommonUtil.nullToString(mCompanyBean.getThreeOneThree()));
        mEditTextArray.get(11).setText(CommonUtil.nullToString(mCompanyBean.getThreeOneFour()));
        mEditTextArray.get(12).setText(CommonUtil.nullToString(mCompanyBean.getThreeOneFive()));
        mEditTextArray.get(13).setText(CommonUtil.nullToString(mCompanyBean.getThreeOneSix()));
        mEditTextArray.get(14).setText(CommonUtil.nullToString(mCompanyBean.getThreeOneSeven()));
        mEditTextArray.get(15).setText(CommonUtil.nullToString(mCompanyBean.getThreeOneEight()));
        mEditTextArray.get(16).setText(CommonUtil.nullToString(mCompanyBean.getThreeTwoOne()));
        mEditTextArray.get(17).setText(CommonUtil.nullToString(mCompanyBean.getThreeTwoTwo()));
        mEditTextArray.get(18).setText(CommonUtil.nullToString(mCompanyBean.getThreeTwoThree()));
        mEditTextArray.get(19).setText(CommonUtil.nullToString(mCompanyBean.getThreeThreeOne()));
        mEditTextArray.get(20).setText(CommonUtil.nullToString(mCompanyBean.getThreeThreeTwo()));
        mEditTextArray.get(21).setText(CommonUtil.nullToString(mCompanyBean.getThreeThreeThree()));
        mEditTextArray.get(22).setText(CommonUtil.nullToString(mCompanyBean.getThreeThreeFour()));
        mEditTextArray.get(23).setText(CommonUtil.nullToString(mCompanyBean.getThreeFourOne()));
        mEditTextArray.get(24).setText(CommonUtil.nullToString(mCompanyBean.getThreeFourTwo()));
        mEditTextArray.get(25).setText(CommonUtil.nullToString(mCompanyBean.getThreeFourThree()));
        mEditTextArray.get(26).setText(CommonUtil.nullToString(mCompanyBean.getThreeFiveOne()));
        mEditTextArray.get(27).setText(CommonUtil.nullToString(mCompanyBean.getThreeFiveTwo()));
        mEditTextArray.get(28).setText(CommonUtil.nullToString(mCompanyBean.getFourOne()));
        mEditTextArray.get(29).setText(CommonUtil.nullToString(mCompanyBean.getFourTwo()));
        mEditTextArray.get(30).setText(CommonUtil.nullToString(mCompanyBean.getFourThree()));
        mEditTextArray.get(31).setText(CommonUtil.nullToString(mCompanyBean.getOpinion()));
    }

    /**
     * 从网络数据初始化EditText的打分值,并保存到数据库
     *
     * @param mEntityBeans
     */
    private void setEditTextOnInternet(EntityBeanSet mEntityBeans) {
        if (mEntityBeans != null && mEntityBeans.getSize() > 0) {
            String opinion="";
            for (int i = 0; i < mEntityBeans.getSize(); i++) {
                EntityBean beans = mEntityBeans.get(i);
                String title = beans.getString("rate");
                double doubleScore = beans.getDouble("score");
                Integer integerScore = new Double(doubleScore).intValue();
                opinion = beans.getString("opinion");
                expertOperations.setText(opinion);
                setEditTextContent(title, integerScore+"");
                updateScoreToDb(title, integerScore+"");
            }
            updateScoreToDb(null,opinion);
        }
    }

    /**
     * 初始化edittext的内容
     * @param title "1.1.1"
     * @param stringScore "分数"
     */
    private void setEditTextContent(String title, String stringScore){
        if(StringUtils.isEmpty(title))return;
        for(int i =0;i<mEditTextArray.size()-1;i++){
            if(mScoreTextArray.get(i).equals(title)){
                mEditTextArray.get(i).setText(stringScore);
                break;
            }
        }
    }



    /**
     * 更新到数据库
     * @param title 打分项目小标题 "1.1.1" ,"1.2.1"......
     * @param stringScore "分数"
     */
    private void updateScoreToDb(String title,String stringScore) {
        ContentValues values = new ContentValues();
        if(title==null){
            values.put("opinion",stringScore);//意见项
            DataSupport.updateAll(CompanyBean.class, values, "companyId = ?",  mId);
            return;
        }
        if ("1.1.1".equals(title)) {
            values.put("oneOne", stringScore);
        } else if ("1.2.1".equals(title)) {
            values.put("oneTwo", stringScore);
        } else if ("2.1.1".equals(title)) {
            values.put("twoOne", stringScore);
        } else if ("2.2.1".equals(title)) {
            values.put("twoTwo", stringScore);
        } else if ("2.3.1".equals(title)) {
            values.put("twoThree", stringScore);
        } else if ("2.4.1".equals(title)) {
            values.put("twoFourOne", stringScore);
        } else if ("2.4.2".equals(title)) {
            values.put("twoFourTwo", stringScore);
        } else if ("2.4.3".equals(title)) {
            values.put("twoFourThree", stringScore);
        } else if ("3.1.1".equals(title)) {
            values.put("threeOneOne", stringScore);
        } else if ("3.1.2".equals(title)) {
            values.put("threeOneTwo", stringScore);
        } else if ("3.1.3".equals(title)) {
            values.put("threeOneThree", stringScore);
        } else if ("3.1.4".equals(title)) {
            values.put("threeOneFour", stringScore);
        } else if ("3.1.5".equals(title)) {
            values.put("threeOneFive", stringScore);
        } else if ("3.1.6".equals(title)) {
            values.put("threeOneSix", stringScore);
        } else if ("3.1.7".equals(title)) {
            values.put("threeOneSeven", stringScore);
        } else if ("3.1.8".equals(title)) {
            values.put("threeOneEight", stringScore);
        } else if ("3.2.1".equals(title)) {
            values.put("threeTwoOne", stringScore);
        } else if ("3.2.2".equals(title)) {
            values.put("threeTwoTwo", stringScore);
        } else if ("3.2.3".equals(title)) {
            values.put("threeTwoThree", stringScore);
        } else if ("3.3.1".equals(title)) {
            values.put("threeThreeOne", stringScore);
        } else if ("3.3.2".equals(title)) {
            values.put("threeThreeTwo", stringScore);
        } else if ("3.3.3".equals(title)) {
            values.put("threeThreeThree", stringScore);
        } else if ("3.3.4".equals(title)) {
            values.put("threeThreeFour", stringScore);
        } else if ("3.4.1".equals(title)) {
            values.put("threeFourOne", stringScore);
        } else if ("3.4.2".equals(title)) {
            values.put("threeFourTwo", stringScore);
        } else if ("3.4.3".equals(title)) {
            values.put("threeFourThree", stringScore);
        } else if ("3.5.1".equals(title)) {
            values.put("threeFiveOne", stringScore);
        } else if ("3.5.2".equals(title)) {
            values.put("threeFiveTwo", stringScore);
        } else if ("4.1.1".equals(title)) {
            values.put("FourOne", stringScore);
        } else if ("4.2.1".equals(title)) {
            values.put("FourTwo", stringScore);
        } else if ("4.3.1".equals(title)) {
            values.put("FourThree", stringScore);
        }
        DataSupport.updateAll(CompanyBean.class, values, "companyId = ?",  mId);
    }
}
